//
//  MBVipProfilePVView.m
//  Meboo
//
//  Created by kyo on 2024/4/28.
//

#import "MBVipProfilePVView.h"
#import "KLPaymentManager.h"
@interface MBVipProfilePVView ()
@property (nonatomic, strong) UILabel *subTitleLab;

@property (nonatomic, strong) UIImageView *typeImageView;
@end

@implementation MBVipProfilePVView

#pragma mark - Life Cycle
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

#pragma mark - Action
//- (void)buyAction {
//    [[KLPaymentManager sharePaymentManager] payWithProductID:@""];
//}

#pragma mark - UI
- (void)setupUI {
//    UITapGestureRecognizer *actionTap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(buyAction)];
//    [self addGestureRecognizer:actionTap];
    
    self.layer.cornerRadius = MBHeightScale(13);
    self.layer.masksToBounds = YES;
    
    //渐变色 设置开始和结束位置(设置渐变的方向)
    CAGradientLayer *gradient = [CAGradientLayer layer];
    gradient.startPoint = CGPointMake(0, 0);
    gradient.endPoint = CGPointMake(1, 1);
    gradient.locations = @[@(0.0),@(1.0f)];
    gradient.frame = CGRectMake(0, 0, (ScreenWidth-MBWidthScale(40))/2, MBHeightScale(74));
    gradient.colors = [NSArray arrayWithObjects:(id)HEXS(@"DEBFFF").CGColor,(id)HEXS(@"EEDEFF").CGColor,nil];
    [self.layer insertSublayer:gradient atIndex:0];
    
    [self addSubview:self.typeImageView];
    [self.typeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.mas_equalTo(MBHeightScale(40));
        make.right.bottom.equalTo(self);
    }];
    
    [self addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(MBHeightScale(12));
        make.centerX.equalTo(self);
    }];
    
    [self addSubview:self.subTitleLab];
    [self.subTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(MBHeightScale(-12));
        make.centerX.equalTo(self);
    }];
}

#pragma mark - Setter && Getter

- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [UILabel new];
        _titleLab.textAlignment = NSTextAlignmentCenter;
        _titleLab.text = [NSString stringWithFormat:@"%ld",[MBUserAccount defaultAccount].checkPVNum];;
        _titleLab.font = MBHelBoldFontSizeScale(24);
        _titleLab.textColor = HEXS(@"000000");
    }
    return _titleLab;
}

- (UILabel *)subTitleLab {
    if (!_subTitleLab) {
        _subTitleLab = [UILabel new];
        _subTitleLab.textAlignment = NSTextAlignmentCenter;
        _subTitleLab.text = @"Inspiration video";
        _subTitleLab.font = PDRegularScale(16);
        _subTitleLab.textColor = HEXS(@"000000");
    }
    return _subTitleLab;
}

- (UIImageView *)typeImageView {
    if (!_typeImageView) {
        _typeImageView = [UIImageView new];
        _typeImageView.image = ImageWithName(@"vipprofile_pv_icon");
    }
    return _typeImageView;
}
@end
